<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
<meta name="keywords" content="天地图"/> 
<title>天地图</title> 
 <%@ include file="App/Common/intoHead.jsp" %>
<script type="text/javascript" src="http://api.tianditu.com/js/maps.js"></script> 
<script type="text/javascript" src="http://api.tianditu.com/js/maptools.js"></script> 
 
<script> 
	var map; 
	var zoom = 10; 
	var markerClusterer; 

	function onLoad() 
	{ 
		//初始化地图对象 
	   	map=new TMap("mapDiv"); 
	   	//设置显示地图的中心点和级别 ,根据当前登录人来确定经纬度
		map.centerAndZoom(new TLngLat(117.8667, 36.333332),zoom); 
		//允许鼠标滚轮缩放地图 
		map.enableHandleMouseScroll(); 
		var pt = ${data};		
				
		//最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。 
		var markers = []; 
		var config = { 
			markers:markers 
		}; 
		var lnglat =[];
		var handler =[];
		for (var i = 0; i < pt.length; i++) { 
		    
			lnglat[i] = new TLngLat(pt[i].longitude, pt[i].latitude);  
			
            marker = new TMarker(lnglat[i]);
		    markers.push(marker); 					
			//markerClusterer = new TMarkerClusterer(map,config);
			handler[i] = TEvent.addListener(marker,"click",function(p){ 
				var lng = this.getLngLat().getLng();
				var lat = this.getLngLat().getLat();
				var btn = document.getElementById("rtuView");
				try{
				//btn.href="http://www.baidu.com";
				var href = $("#rtuView").attr("href");//"<%=request.getContextPath()%>/equi/selectEqui.do";
				var str = href.split("?");
				href = str[0] + "?longitude=" + lng +"&latitude=" + lat;	
				$("#rtuView").attr("href",href);
				alert($("#rtuView").attr("href"));
				//window.showModalDialog(href,"","dialogWidth=800px;dialogHeight=500px");
				$("#rtuView").click();
				}catch(e){}
           // alert("标注当前坐标："+this.getLngLat().getLng()+","+this.getLngLat().getLat()); 
            });
	
		} 
		
		//最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。 
		markerClusterer = new TMarkerClusterer(map,config);
	} 
	 
</script> 
</head> 
<body onLoad="onLoad()"> 
    <div style="width:100%;height:40px;background-color:#FFFFFF;">
     <a href="<%=request.getContextPath()%>/equi/selectEqui.do" id="rtuView" data-toggle="navtab" data-id="equiView" data-title="查看设备"></a>
   </div>
	<div id="mapDiv" style="position:absolute;width:100%; height:99%"></div> 
	
</body> 
</html>